using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace Test {
	class RfIps {
		//handsets that point not to the right warehouse
		static void MainX() {
			SQL local=new SQL("server=localhost;database=repotest;integrated security=sspi;");
			string qry=@"select distinct site,n.network,whs,rfSrv,dbSrv,dbState from rfDStat s 
join RfNetwork n on n.network=s.network join RfWhs w on whs=w.name
where site not in('Netscaler','Systems EW','Toftshaw')and n.site!=s.whs order by 1";
			DataTable tab=local.Query(qry);
			foreach(DataRow row in tab.Rows)
			{
				SQL remote=new SQL(row["dbSrv"].ToString(),row["dbState"].ToString());
				DataTable ips=remote.Query("select distinct address from RfState where address like '{0}.%' and address not in('172.26.15.5')and lastupdate>getdate()-15",row["network"]);
				if(ips.Rows.Count==0)
					continue;
				Console.WriteLine("From:{0} network({3}), To:{1}({2})",row["site"],row["whs"],row["rfSrv"],row["network"]);
				foreach(DataRow ip in ips.Rows)
					Console.WriteLine(ip["address"].ToString().Trim());
			}
		}
	}
}
